package santeclair.referentiel.bean;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import santeclair.lunar.framework.annotation.Code;

@Entity
@Table(name = "tr_domaine_global", catalog = "referentiel", uniqueConstraints = @UniqueConstraint(columnNames = "code_domaine_global"))
public class DomaineGlobal implements Serializable {

    private static final long serialVersionUID = -5477249811125922660L;

    @Id
    @Column(name = "identifiant_domaine_global", unique = true, nullable = false)
    private Integer id;

    @Code
    @Column(name = "code_domaine_global", unique = true, nullable = false, length = 10)
    private String code;

    @Column(name = "libelle_domaine_global", nullable = false)
    private String libelle;

    /* ======================================================= *
     *                      getters & setters 
     * ======================================================= */

    public Integer getIdentifiant() {
        return this.id;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String codeDomaine) {
        this.code = codeDomaine;
    }

    public String getLibelle() {
        return this.libelle;
    }

    public void setLibelle(String libelleDomaine) {
        this.libelle = libelleDomaine;
    }

    /* ======================================================= *
     *                      equals
     * ======================================================= */

    /** {@inheritDoc} */
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        DomaineGlobal other = (DomaineGlobal) obj;
        if (code == null) {
            if (other.code != null)
                return false;
        } else if (!code.equals(other.code))
            return false;
        return true;
    }

}
